package com.tian.test.controller.document;

import com.tian.test.domain.RequestModel;
import com.tian.test.domain.ResultModel;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试地址")
@RestController
@RequestMapping("/api")
public class InterfaceHtmlController {
    @ApiOperation(value = "admin测试接口", notes = "参数信息", produces = "application/json")
    @ApiImplicitParam(name = "name", value = "名称", paramType = "query", required = true, dataType = "String")
    @ResponseBody
    @GetMapping("/adminApi/testOne")
    public String testOne(String name) {
        return name;
    }

    @ApiOperation(value = "user测试接口", notes = "参数信息", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "姓名", paramType = "query", required = true, dataType = "String", example = "天之涯"),
            @ApiImplicitParam(name = "age", value = "年龄", paramType = "query", required = true, dataType = "String", example = "18")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "正常数据返回", response = ResultModel.class)
    })
    @ResponseBody
    @GetMapping("/userApi/testTwo")
    public ResultModel testTwo(String name, String age) {
        ResultModel model = new ResultModel();
        model.setMsg("姓名：" + name + " 年龄：" + age);
        return model;
    }

    @ApiOperation(value = "admin测试接口接收对象", notes = "参数信息", produces = "application/json")
    @ResponseBody
    @GetMapping("/adminApi/testThree")
    public ResultModel testThree(RequestModel requestModel) {
        ResultModel model = new ResultModel();
        model.setMsg("姓名：" + requestModel.getName() + " 年龄：" + requestModel.getAge());
        return model;
    }
}
